//希尔排序

#include <stdio.h>

void shell_sort(int *arr, int len);
void show(int *arr, int len);

int main()
{
    int drr[] = {1, 8, 7, 5, 0};
    //sizeof()它的作用是返回一个对象或类型所占的内存的字节数
    int num = sizeof(drr) / sizeof(drr[0]);
    shell_sort(drr, num);
    show(drr, num);
    return 0;
}

void shell_sort(int *arr, int size)
{
    int i, j, tmp, increment;
    for (increment = size / 2; increment > 0; increment /= 2)
    {
        for (i = increment; i < size; i++)
        {
            tmp = arr[i];
            for (j = i - increment; j >= 0 && tmp < arr[j]; j -= increment)
            {
                arr[j + increment] = arr[j];
            }
            arr[j + increment] = tmp;
        }
    }
}

void show(int *arr, int len)
{
    for (int i = 0; i < len; i++)
    {
        printf("%d ", arr[i]);
    }
    printf("\n");
}